public without sharing class CaseSmsHandler {
    // 发送短信
    public static void sendSmsInfo(List<Case> list_new, Map<Id, Case> map_old) {
        // 新建时发送短信，模板编号2291012018624
        String test = '111';
         String test1 = '111';
        /*if (map_old == null) {
            for (Case c : list_new) {
                if (String.isBlank(c.ContactMobile__c) == false && String.isBlank(c.User__c) == false && c.isSendAcceptCaseSMS__c == false) {
                    String smsMessage = Utils.getSMSTemplate('个案受理');
                    smsMessage = smsMessage.replace('{ContactName}', c.ContactName__c);
                    smsMessage = smsMessage.replace('{CaseNumber}', c.CaseNumber);
                    Utils.sendSmsMessage(c.ContactMobile__c, smsMessage);
                   // c.isSendAcceptCaseSMS__c = true;///标记已经发送了受理短信
                }
               ////电话处理完成
                if (String.isBlank(c.ContactMobile__c) == false && String.isBlank(c.User__c) == false&& String.isBlank(c.ProfessionalName__c) == false && c.TelDealComplete__c == true) {
                    String smsMessage = Utils.getSMSTemplate('电话处理完成');
                    smsMessage = smsMessage.replace('{accountName}', c.AccountName__c);
                    smsMessage = smsMessage.replace('{expectName}', c.ProfessionalName__c);
                    Utils.sendSmsMessage(c.ContactMobile__c, smsMessage);
                }
            }
            
            
        }
        // 更新时
        else {
            for (Case c : list_new) {

                ///如果之前没有发送受理短信 则发送受理短信
                if (String.isBlank(c.ContactMobile__c) == false && String.isBlank(c.User__c) == false && c.isSendAcceptCaseSMS__c == false) {
                    String smsMessage = Utils.getSMSTemplate('个案受理');
                    smsMessage = smsMessage.replace('{ContactName}', c.ContactName__c);
                    smsMessage = smsMessage.replace('{CaseNumber}', c.CaseNumber);
                    Utils.sendSmsMessage(c.ContactMobile__c, smsMessage);
                    c.isSendAcceptCaseSMS__c = true;///标记已经发送了受理短信
                }
                
                
                Case oldCase = map_old.get(c.Id);
                System.debug(c.ContactMobile__c + c.User__c + oldCase.TelDealComplete__c +c.TelDealComplete__c);
                 ///电话处理完成
                if (String.isBlank(c.ContactMobile__c) == false&& String.isBlank(c.ProfessionalName__c) == false&& oldCase.TelDealComplete__c==false &&c.TelDealComplete__c == true) {
                    String smsMessage = Utils.getSMSTemplate('电话处理完成');
                    smsMessage = smsMessage.replace('{accountName}', c.AccountName__c);
                    smsMessage = smsMessage.replace('{expectName}', c.ProfessionalName__c);
                    Utils.sendSmsMessage(c.ContactMobile__c, smsMessage);
                }
                // 已派发（已选择了工程师），模板编号2291012018625
                // if (oldCase.Status != c.Status && c.Status == '已分配') {
                //     if (String.isBlank(c.ContactMobile__c) == false) {
                //         String smsMessage = Utils.getSMSTemplate('工程师出发');
                //         smsMessage = smsMessage.replace('{ContactName}', c.ContactName__c);
                //         smsMessage = smsMessage.replace('{EngineerName}', c.EngineerName__c);
                //         smsMessage = smsMessage.replace('{DepartTime}', c.LastModifiedDate.format('yyyy年M月d日H点m分'));
                //         Utils.sendSmsMessage(c.ContactMobile__c, smsMessage);
                //     }
                // }
                // 完成（工程师签字之后）
                if (oldCase.SendSatisfySms__c != c.SendSatisfySms__c && c.SendSatisfySms__c == true) {
                    if (String.isBlank(c.ContactMobile__c) == false) {
                        String smsMessage = '';
                        // 判断个案下是否有多个工单
                        List<WorkOrder__c> woList = [select Id from WorkOrder__c where Case__c = :c.Id];
                        // 多个工单的个案，模板编号2291012021330
                        if (woList.size() > 1) {
                            smsMessage = Utils.getSMSTemplate('保养服务完成');
                            smsMessage = smsMessage.replace('{AccountName}', c.AccountName__c);
                            smsMessage = smsMessage.replace('{EngineerName}', c.EngineerName__c);
                        }
                        // 单个工单的个案，模板编号2291012018626
                        else {
                            smsMessage = Utils.getSMSTemplate('服务完成');
                            smsMessage = smsMessage.replace('{ProductName}', c.ProductName__c);
                            smsMessage = smsMessage.replace('{IMEINumber}', String.isBlank(c.IMEINumber__c) == true ? '' : c.IMEINumber__c);
                            smsMessage = smsMessage.replace('{EngineerName}', c.EngineerName__c);
                        }
                        Utils.sendSmsMessage(c.ContactMobile__c, smsMessage);
                    }
                }
            } 
        }*/
    }
}